using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MyMES.Dto;
using MyMES.IServices.WorkforceManagement;
using System.Threading.Tasks;
using VOL.Core.Controllers.Basic;
using VOL.Core.Filters;
using VOL.Core.Utilities.Response;
using VOL.Entity.AttributeManager;

namespace VOL.WebApi.Controllers.MyMES
{
    /// <summary>
    /// 工作排班管理控制器
    /// </summary>
    [Route("api/Workforce")]
    [ApiController]
    [AllowAnonymous] // 允许匿名访问，实际项目中应根据需要配置权限
    [PermissionTable(Name = "Workforce")]
    public class WorkforceController : ApiBaseController<IWorkforceService>
    {
        private readonly IWorkforceService _workforceService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="workforceService">工作排班服务</param>
        public WorkforceController(IWorkforceService workforceService)
            : base(workforceService)
        {
            _workforceService = workforceService;
        }

        /// <summary>
        /// 获取工作日历（POST方法）
        /// </summary>
        /// <param name="dto">查询参数</param>
        /// <returns>工作日历数据</returns>
        [HttpPost("GetWorkforceCalendar")]
        public async Task<WebResponseContent> GetWorkforceCalendar([FromBody] GetWorkforceCalendarDto dto)
        {
            return await _workforceService.GetWorkforceCalendar(dto);
        }
        
        /// <summary>
        /// 获取工作日历（GET方法）
        /// </summary>
        /// <param name="year">年份</param>
        /// <param name="month">月份</param>
        /// <param name="groupId">班组ID（可选）</param>
        /// <param name="groupName">班组名称（可选）</param>
        /// <param name="groupType">班组类型（可选）</param>
        /// <param name="onlyHolidays">是否只查询假期（可选）</param>
        /// <returns>工作日历数据</returns>
        [HttpGet("GetWorkforceCalendar")]
        public async Task<WebResponseContent> GetWorkforceCalendarByGet(GetWorkforceCalendarDto dto)
        {
            
            return await _workforceService.GetWorkforceCalendar(dto);
        }
        
        /// <summary>
        /// 获取班组列表
        /// </summary>
        /// <returns>班组列表数据</returns>
        [HttpGet("GetTeamList")]
        public async Task<WebResponseContent> GetTeamList()
        {
            return await _workforceService.GetTeamList();
        }
        
        /// <summary>
        /// 获取班组类型列表
        /// </summary>
        /// <returns>班组类型列表数据</returns>
        [HttpGet("GetTeamTypeList")]
        public async Task<WebResponseContent> GetTeamTypeList()
        {
            return await _workforceService.GetTeamTypeList();
        }
    }
} 